﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using JVP.Gateway;

namespace JeevanVaisya
{
    public partial class ChangePassword : Form
    {
        string user;
        Gateway gateway = new Gateway();

        public ChangePassword(string userName)
        {
            InitializeComponent();

            user = userName;

            btnChange.Click += new EventHandler(btnChange_Click);
            btnCancel.Click += new EventHandler(btnCancel_Click);
        }

        void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
            this.Dispose();
        }

        void btnChange_Click(object sender, EventArgs e)
        {
            if (txtNewPass.Text == txtRePass.Text)
            {
                if (gateway.changePassword(user, txtOldPass.Text, txtNewPass.Text))
                {
                    MessageBox.Show("Password Successfully Changed");
                    clearing();
                }
                else
                    MessageBox.Show("Invalid Process");
            }
        }

        private void clearing()
        {
            txtOldPass.Text = "";
            txtNewPass.Text = "";
            txtRePass.Text = "";
        }
    }
}
